package com.business.api.official.toursism.websitecomment.manager.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.business.api.official.toursism.websitecomment.manager.WebsiteCommentApiManager;
import com.business.api.official.toursism.websitecomment.mapper.WebsiteCommentApiMapper;
import com.business.api.official.toursism.websitecomment.vo.WebsiteCommentApiBriefListVO;
import com.business.api.official.toursism.websitecomment.vo.WebsiteCommentApiBriefVO;
import com.business.api.official.toursism.websitecomment.vo.WebsiteCommentApiDetailListVO;
import com.business.api.official.toursism.websitecomment.vo.WebsiteCommentApiDetailVO;
import com.business.api.official.toursism.websitecomment.vo.data.WebsiteCommentApiBriefData;
import com.business.api.official.toursism.websitecomment.vo.data.WebsiteCommentApiDetailData;
import com.business.system.official.toursism.websitecomment.entity.WebsiteComment;
import com.business.system.official.toursism.websitecomment.manager.WebsiteCommentManager;
import com.seed.core.exception.ManagerException;
import com.seed.core.pojo.manager.impl.SeedApiManagerImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @description 评论
 * @author CodeGenerator
 * @date   2025-01-25
 * @version V1.0
 */
@Slf4j
@Service("websiteCommentApiManager")
@Transactional(rollbackFor = ManagerException.class)
public class WebsiteCommentApiManagerImpl extends SeedApiManagerImpl<WebsiteCommentApiMapper, WebsiteComment> implements WebsiteCommentApiManager {
    @Autowired
    private WebsiteCommentManager systemManager;

    /**
     * 根据id获取详情VO data
     *
     * @param websiteCommentId 对象id
     * @return 详情VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiDetailData convertApiDetailData(String websiteCommentId) throws ManagerException {
        WebsiteComment websiteComment = this.getById(websiteCommentId);
        return this.convertApiDetailData(websiteComment);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteComment model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiDetailData convertApiDetailData(WebsiteComment websiteComment) throws ManagerException {
        WebsiteCommentApiDetailData websiteCommentApiDetailData = new WebsiteCommentApiDetailData();
        try {
            BeanUtils.copyProperties(websiteComment, websiteCommentApiDetailData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteComment);
        }
        return websiteCommentApiDetailData;
    }

    /**
     * 根据id获取详情VO
     *
     * @param websiteCommentId 对象id
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiDetailVO getApiDetailVO(String websiteCommentId) throws ManagerException {
        WebsiteCommentApiDetailData websiteCommentApiDetailData = this.convertApiDetailData(websiteCommentId);
        return new WebsiteCommentApiDetailVO(websiteCommentApiDetailData);
    }

    /**
     * 根据对象获取详情VO
     *
     * @param websiteComment 对象
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiDetailVO getApiDetailVO(WebsiteComment websiteComment) throws ManagerException {
        WebsiteCommentApiDetailData websiteCommentApiDetailData = this.convertApiDetailData(websiteComment);
        return new WebsiteCommentApiDetailVO(websiteCommentApiDetailData);
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteCommentApiDetailData> getConvertApiDetailListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteComment> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteComment::getId, ids);
        List<WebsiteComment> websiteCommentList = this.list(queryWrapper);
        return this.listConvertApiDetailData(websiteCommentList);
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteCommentApiDetailData> listConvertApiDetailData(Wrapper<WebsiteComment> queryWrapper) throws ManagerException {
        List<WebsiteComment> websiteCommentList = this.list(queryWrapper);
        return this.listConvertApiDetailData(websiteCommentList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteCommentList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteCommentApiDetailData> listConvertApiDetailData(List<WebsiteComment> websiteCommentList) throws ManagerException {
        List<WebsiteCommentApiDetailData> websiteCommentApiDetailDataList = new ArrayList<>();
        for (WebsiteComment websiteComment : websiteCommentList) {
            websiteCommentApiDetailDataList.add(this.convertApiDetailData(websiteComment));
        }
        return websiteCommentApiDetailDataList;
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiDetailListVO getApiDetailListVOByIds(List<String> ids) throws ManagerException {
        return new WebsiteCommentApiDetailListVO(this.getConvertApiDetailListVOByIds(ids));
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiDetailListVO getApiDetailListVO(Wrapper<WebsiteComment> queryWrapper) throws ManagerException {
        return new WebsiteCommentApiDetailListVO(this.listConvertApiDetailData(queryWrapper));
    }

    /**
     * 根据对象list获取详情VO data list
     *
     * @param websiteCommentList 对象list
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiDetailListVO getApiDetailListVO(List<WebsiteComment> websiteCommentList) throws ManagerException {
        return new WebsiteCommentApiDetailListVO(this.listConvertApiDetailData(websiteCommentList));
    }

    /**
     * 根据id获取简略VO data
     *
     * @param websiteCommentId 对象id
     * @return 简略VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiBriefData convertApiBriefData(String websiteCommentId) throws ManagerException {
        WebsiteComment websiteComment = this.getById(websiteCommentId);
        return this.convertApiBriefData(websiteComment);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteComment model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiBriefData convertApiBriefData(WebsiteComment websiteComment) throws ManagerException {
        WebsiteCommentApiBriefData websiteCommentApiBriefData = new WebsiteCommentApiBriefData();
        try {
            BeanUtils.copyProperties(websiteComment, websiteCommentApiBriefData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteComment);
        }
        return websiteCommentApiBriefData;
    }

    /**
     * 根据id获取简略VO
     *
     * @param websiteCommentId 对象id
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiBriefVO getApiBriefVO(String websiteCommentId) throws ManagerException {
        WebsiteCommentApiBriefData websiteCommentApiBriefData = this.convertApiBriefData(websiteCommentId);
        return new WebsiteCommentApiBriefVO(websiteCommentApiBriefData);
    }

    /**
     * 根据对象获取简略VO
     *
     * @param websiteComment 对象
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiBriefVO getApiBriefVO(WebsiteComment websiteComment) throws ManagerException {
        WebsiteCommentApiBriefData websiteCommentApiBriefData = this.convertApiBriefData(websiteComment);
        return new WebsiteCommentApiBriefVO(websiteCommentApiBriefData);
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteCommentApiBriefData> listConvertApiBriefDataByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteComment> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteComment::getId, ids);
        List<WebsiteComment> websiteCommentList = this.list(queryWrapper);
        return this.listConvertApiBriefData(websiteCommentList);
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteCommentApiBriefData> listConvertApiBriefData(Wrapper<WebsiteComment> queryWrapper) throws ManagerException {
        List<WebsiteComment> websiteCommentList = this.list(queryWrapper);
        return this.listConvertApiBriefData(websiteCommentList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteCommentList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteCommentApiBriefData> listConvertApiBriefData(List<WebsiteComment> websiteCommentList) throws ManagerException {
        List<WebsiteCommentApiBriefData> websiteCommentApiBriefDataList = new ArrayList<>();
        for (WebsiteComment websiteComment : websiteCommentList) {
            websiteCommentApiBriefDataList.add(this.convertApiBriefData(websiteComment));
        }
        return websiteCommentApiBriefDataList;
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiBriefListVO getApiBriefListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteComment> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteComment::getId, ids);
        List<WebsiteComment> websiteCommentList = this.list(queryWrapper);
        return new WebsiteCommentApiBriefListVO(this.listConvertApiBriefData(websiteCommentList));
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiBriefListVO getApiBriefListVO(Wrapper<WebsiteComment> queryWrapper) throws ManagerException {
        List<WebsiteComment> websiteCommentList = this.list(queryWrapper);
        return new WebsiteCommentApiBriefListVO(this.listConvertApiBriefData(websiteCommentList));
    }

    /**
     * 根据对象list获取简略VO data list
     *
     * @param websiteCommentList 对象list
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteCommentApiBriefListVO getApiBriefListVO(List<WebsiteComment> websiteCommentList) throws ManagerException {
        return new WebsiteCommentApiBriefListVO(this.listConvertApiBriefData(websiteCommentList));
    }
}